package define.Demo_02.Goods;

public class GoodsTest {
    public static void main(String[] args) {
        //1.创建一个数组
        Goods[] arr = new Goods[3];
        //2.创建商品对象x3
        Goods goods1 = new Goods("001", "Apple", 6000, 100);
        Goods goods2 = new Goods("002", "HuaWei", 5000, 150);
        Goods goods3 = new Goods("003", "Cup", 4.0, 200);
        //3.将商品对象放入数组中
        arr[0] = goods1;
        arr[1] = goods2;
        arr[2] = goods3;
        //4.遍历数组

        for (int i = 0; i < arr.length; i++) {
            Goods goods = arr[i];
            System.out.println(goods.getId() + "\t" + goods.getName() + "\t" + goods.getPrice() + "\t" + goods.getCount());
        }

    }
}
